package com.spring.theory.spi;

import java.util.Iterator;
import java.util.ServiceLoader;

import sun.misc.Service;

/**
 * SpiExcuter
 *
 * @author 24373
 * @version 1.0
 * @date 2024-06-01 18:23
 */
public class SpiExcuter {

    public static void main(String[] args) {

        Iterator<TestSpi> providers = Service.providers(TestSpi.class);
        while (providers.hasNext()) {
            TestSpi next = providers.next();
            next.excute();
        }

        ServiceLoader<TestSpi> load = ServiceLoader.load(TestSpi.class);
        Iterator<TestSpi> iterator = load.iterator();
        while (iterator.hasNext()) {
            TestSpi ser = iterator.next();
            ser.excute();
        }

    }

}
